#include "base/base.h"

namespace scoped {
class Test {
  public:
    Test() {
      LOG(INFO)<< "Test construct";
    }

    void Print () {
      LOG(INFO) << "print methord";
    }

    ~Test () {
      LOG(INFO) << "test deconstruct";
    }
  };

class TestCounter : public RefCount {
  public:
    TestCounter() {
      LOG(INFO)<< "TestCounter construct";
    }

    void Print () {
      LOG(INFO) << "count: " << Count();
    }

    ~TestCounter () {
      LOG(INFO) << "TestCounter deconstruct";
    }

    private:
    DISALLOW_COPY_AND_ASSIGN(TestCounter);
  };

int test_scoped_ptr() {
  // test for scoped_ptr
  scoped_ptr<Test> test(new Test);
  test.reset(NULL);

  test.reset(new Test);
  test->Print();
  Test* t = test.release();
  delete t;

  // test for scoped_ref
  {
    scoped_ref<TestCounter> ref(new TestCounter);
    ref->Print();
    ref = ref.get();
  }

}
}
